package com.yc.baihe.servlets;

import java.io.File;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import com.yc.baihe.utils.UploadUtil;

public class InitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private String path="../upload";
	
	public void init() throws ServletException{
		//说明给了初始化参数
		if(this.getInitParameter("uploadPath")!=null){
			path=this.getInitParameter("uploadPath");
		}
		
		//判断这个路径是否存在
		File file=new File(this.getServletContext().getRealPath(path));
		if(!file.exists()){
			file.mkdirs();
		}
		
		UploadUtil.PATH=path;
		
		super.init();
	}

}
